﻿<UserControl x:Class="PurchaseSales.Manage.Views.CustomerView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
      x:Name="userControl" >
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding LoadCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Grid>
        <DockPanel >
            <UniformGrid   HorizontalAlignment="Right" Margin="10" DockPanel.Dock="Bottom">
                <UniformGrid.Rows>1</UniformGrid.Rows>
                <Button Content="添加" FontSize="14" MinWidth="80" Style="{DynamicResource SquareButtonStyle}" Margin="5"  FontFamily="Microsoft JhengHei, Segoe UI, PMingLiU" Command="{Binding AddCommand}"/>
                <Button Content="编辑" FontSize="14" MinWidth="80" Style="{DynamicResource SquareButtonStyle}" Margin="5"  FontFamily="Microsoft JhengHei, Segoe UI, PMingLiU" Command="{Binding EditCommand}"/>
                <Button Content="删除" FontSize="14" Style="{DynamicResource SquareButtonStyle}" Margin="5" IsCancel="True" FontFamily="Microsoft JhengHei, Segoe UI, PMingLiU" Command="{Binding RemoveCommand}"/>
            </UniformGrid>
            <ListBox x:Name="CustoemrList"  ItemsSource="{Binding Customers}" Background="Gray">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="SnapsToDevicePixels" Value="true"/>
                        <Setter Property="OverridesDefaultStyle" Value="true"/>
                        <Setter Property="VerticalContentAlignment" Value="Top"/>
                        <Setter Property="HorizontalContentAlignment" Value="Left"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Grid SnapsToDevicePixels="true" Margin="5" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
								HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                                        <ContentPresenter/>
                                        <Border  x:Name="Checked" BorderThickness="3" BorderBrush="#FF41B1E1">
                                            <Grid>
                                                <Path Width="33" Height="33" Stretch="Fill"  HorizontalAlignment="Right" VerticalAlignment="Top"  Fill="#FF41B1E1" Data="F1 M 294.469,237.943L 307.781,237.943L 307.781,250.276"/>
                                                <Path Width="16" Height="14" Fill="White"  Data="F1 M 263.89,239.418L 265.043,240.571L 267.402,238.212L 267.912,238.722L 265.553,241.081L 265.553,241.081L 265.043,241.591L 265.043,241.591L 264.533,241.081L 263.38,239.928L 263.89,239.418 Z " 
                                       HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="Fill" Margin="0,1,1,0"/>
                                            </Grid>
                                        </Border>
                                        <ToolTipService.ToolTip>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition/>
                                                    <RowDefinition/>
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition/>
                                                    <ColumnDefinition/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Text="姓名：" VerticalAlignment="Center"/>
                                                <TextBlock Text="电话号码：" Grid.Row="1" VerticalAlignment="Center"/>

                                                <TextBlock Text="{Binding Name}" Grid.Column="1" VerticalAlignment="Center"/>
                                                <TextBlock Text="{Binding Phone}" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center"/>
                                            </Grid>
                                        </ToolTipService.ToolTip>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsSelected" Value="true">
                                            <Setter TargetName="Checked" Property="Visibility" Value="Visible"/>
                                        </Trigger>
                                        <Trigger Property="IsSelected" Value="false">
                                            <Setter TargetName="Checked" Property="Visibility" Value="Hidden"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel HorizontalAlignment="{TemplateBinding HorizontalAlignment}" 
					VerticalAlignment="{TemplateBinding VerticalAlignment}"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border Background="White" HorizontalAlignment="Left" VerticalAlignment="Top" Height="80" Width="100"
                            Padding="5">
                            <TextBlock Text="{Binding Name}" FontSize="18" VerticalAlignment="Bottom"/>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <i:InvokeCommandAction Command="{Binding SelectedCustomerCommand}" 
                                           CommandParameter="{Binding ElementName=CustoemrList, Path=SelectedItem}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </ListBox>
        </DockPanel>
        <TextBlock  Margin="0 0 -10 50" FontSize="94" FontFamily="Segoe UI" Foreground="#C4E1FF" Text="{Binding Customers.Count}" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
    </Grid>

</UserControl>
